package com.example.service;

import com.example.entity.VideoRecord;
import com.example.mapper.VideoRecordMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
帖子业务处理
 */
@Service
public class VideoRecordService {

    @Resource
    private VideoRecordMapper videoRecordMapper;

    public void add(VideoRecord videoRecord) {
        videoRecordMapper.insert(videoRecord);
    }

    public void deleteById(Integer id) {
        videoRecordMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(VideoRecord videoRecord) {
        videoRecordMapper.updateById(videoRecord);
    }

    public VideoRecord selectById(Integer id) {
        return videoRecordMapper.selectById(id);
    }

    public List<VideoRecord> selectAll(VideoRecord videoRecord) {
        return videoRecordMapper.selectAll(videoRecord);
    }

    public PageInfo<VideoRecord> selectPage(VideoRecord videoRecord, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<VideoRecord> videoRecordList = videoRecordMapper.selectAll(videoRecord);
        return PageInfo.of(videoRecordList);
    }

    public void deleteAll() {
        videoRecordMapper.deleteAll();

    }
}
